<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * @abstract 打印条码接口
 * @author zxj
 *
 */
class PrintBarcode extends CI_Controller {
	private  $t_barcode = 'print_barcode_list';
	function __construct() {
		parent::__construct();
	}


	/**
	 * 条码列表
	 */
	function get_barcodeList() {
        $message = ''; $success = false; $data = '';
        $idsData = gp();
        if($idsData && is_array($idsData)){
            foreach ($idsData as $rs) {
                $barcodeFirst = $this->common_model->selectFirst($this->t_barcode,array('id'=>$rs['source_id']));
                if(!$barcodeFirst)continue;
                $this->common_model->update($this->t_barcode,array('is_instor'=>1,'is_sync'=>1),array('id'=>$rs['source_id']));
                $trackOne = $this->common_model->selectFirst('maintain_track',array('maintain_id'=>$barcodeFirst['oid'],'target_status'=>22));
                if(!$trackOne) {
                    //维修轨迹
                    $trackData = array(
                        'maintain_id' => $barcodeFirst['oid'], 'add_time' => date('Y-m-d H:i:s'),
                        'target_status' => 22, 'modified_user' => $rs['name']
                    );
                    $this->common_model->insert('maintain_track', $trackData);
                }
                $this->common_model->update('maintain_order',array('status_id'=>'22'),array('maintain_id'=>$barcodeFirst['oid']));
            }
            json_output($idsData,'请求成功！！！',true);
        }

		//查询返回的数组
		$dataList = $this->common_model->selectCustom($this->t_barcode,array('is_sync'=>0));
		//重构数据
		foreach ($dataList as $key=>&$vary ) {
            $vary['is_sync_as'] = $vary['is_sync']?'已同步':'未同步';
		}
        unset($vary);

		//json判断处理
		if (empty($dataList)) {
			$message = '没有更多数据....';
		}else{
			$message = '返回成功';
            $success = true;
		}
		json_output($dataList,$message,$success);
	}





}
